import request from '@/utils/request';

/** 新增辅材信息 */
export const addAuxiliaryApi = (data: any) => {
    return request({
        url: '/system/auxiliaryMaterials',
        method: 'post',
        data: data
    });
};

/** 导出辅材信息列表 */
export const exportAuxiliaryApi = (data: any) => {
    return request({
        url: '/system/auxiliaryMaterials/export',
        method: 'post',
        data: data
    });
};

/** 查询辅材信息列表 */
export const getAuxiliaryListApi = (data: any) => {
    return request({
        url: '/system/auxiliaryMaterials/list',
        method: 'post',
        data: data
    });
};

/** 获取辅材信息详细信息 */
export const getAuxiliaryByIdApi = (id: string|number|undefined)=>{
    return request({
        url:`/system/auxiliaryMaterials/${id}`,
        method: 'get'
    });
};

/** 材料大类，小类，获取对应的辅材列表 */
export const getAuxiliaryByTypeApi = ( major: string, sub: string ) => {
    return request({
        url:`/system/auxiliaryMaterials/getAuxiliaryMaterialsByMaterialType`,
        method: 'get',
        params: {majorType: major, subclassType: sub}
    });
};

/** 修改辅材信息 */
export const updateAuxiliaryApi = (data: any) => {
    return request({
        url: '/system/auxiliaryMaterials',
        method: 'put',
        data: data
    });
};

/** 辅材信息放入回收站 */
export const deleteAuxiliaryApi = (id: any) => {
    return request({
        url: '/system/auxiliaryMaterials/recycleBin',
        method: 'delete',
        params: {id: id, delFLag: 1}
    });
};

/** 撤销辅材信息放入回收站 */
export const revokeAuxiliaryApi = (id: any) => {
    return request({
        url: '/system/auxiliaryMaterials/recycleBin',
        method: 'delete',
        params: {id: id, delFLag: 0}
    });
};

/** 获取回收站中的辅材信息 */
export const getCycleBinAuxiliaryListApi = (data: any) => {
    return request({
        url: '/system/auxiliaryMaterials/recycleBinList',
        method: 'post',
        data: data
    });
};

/** 彻底删除辅材 */
export const totalDeleteAuxiliaryApi = (id: any) => {
    return request({
        url: '/system/auxiliaryMaterials/removeById',
        method: 'delete',
        params: {id: id}
    });
};

/** 根据辅材编号获取采购数据 */
export const getAuxiliaryPurchaseInfoApi = (id: any) => {
    return request({
        url: '/system/auxiliaryPurchaseOrder/getPurchaseOrderDetail',
        method: 'get',
        params: {auxiliaryId: id}
    });
};

/** 新增辅材采购单 */
export const addAuxiliaryPurchaseApi = (data: any) => {
    return request({
        url: '/system/auxiliaryPurchaseOrder',
        method: 'post',
        data: data
    });
};

/** 查询辅材采购单列表 */
export const getAuxiliaryPurchaseApi = (data: any) => {
    return request({
        url: '/system/auxiliaryPurchaseOrder',
        method: 'post',
        data: data
    });
};

/** 根据辅材id获取采购单列表 */
export const getAuxiliaryPurchaseByIdApi = (id: any) => {
    return request({
        url: '/system/auxiliaryPurchaseOrder/getByAuxiliaryId',
        method: 'get',
        params: {auxiliaryId: id}
    });
};

/** 新增辅材入库记录 */
export const auxiliaryInStorageApi = (data: any) => {
    return request({
        url: '/system/auxiliaryInRecord',
        method: 'post',
        data: data
    });
};

/** 新增辅材出库记录 */
export const auxiliaryOutStorageApi = (data: any) => {
    return request({
        url: '/system/auxiliaryOutRecord',
        method: 'post',
        data: data
    });
};

/** 新增辅材包装件(四个) */
export const addPackageApi = (data: any) => {
    return request({
        url: '/system/auxiliaryJoinPacking',
        method: 'post',
        data: data
    });
};

/** 获取辅材包装件详细信息 */
export const getPackageDetailApi = (auxiliaryId: any) => {
    return request({
        url: `/system/auxiliaryJoinPacking/${auxiliaryId}`,
        method: 'get'
    });
};

/** 新增辅材包装订单 */
export const addPackagingOrderApi = (data: any) => {
    return request({
        url: '/system/auxiliaryPackingOrder',
        method: 'post',
        data: data
    });
};

/** 新增不锈钢定制单 */
export const addStainlesssteelOrderApi = (data: any) => {
    return request({
        url: '/system/auxiliaryJoinStainlessSteel',
        method: 'post',
        data: data
    });
};

/** 获取所有子公司 */
export const getAllSubsidiaryApi = () => {
    return request({
        url: '/system/companyInformation/getAllCompany',
        method: 'get'
    });
};